<?php
/**
 * Created by PhpStorm.
 * 资料清单模板
 * User: xuewl
 * Date: 2017/12/21
 * Time: 02:06
 */

namespace app\product\service;
use app\common\library\Service;

class ProfileTemplate extends Service
{
    use \app\common\library\traits\Model;

    protected $model;

    public function _initialize()
    {
        parent::_initialize();
        $this->model = model('product/profile_template');
    }

    /**
     * 创建资料清单
     * @param string $title
     * @param array $content
     * @param integer $product_id
     * @param integer $owner_aid
     * @return boolean
     */
    public function create($title, $content, $product_id, $owner_aid) {
        $info = [
            'product_id' => $product_id,
            'title' => $title,
            'content' => $content,
            'owner_aid' => $owner_aid,
        ];
        $info['is_system'] = defined("IN_ADMIN") ? 1 : 0;
        $result = $this->save($info, []);
        if(!$result) {
            $this->error = $this->getError();
            return false;
        }
        return $result;
    }
}